package com.onion.auth.handler;

import com.onion.auth.context.AclContext;
import com.onion.auth.support.AuthManager;
import com.onion.auth.support.SecurityContexts;
import com.onion.auth.support.vo.AuthUser;

public class TokenUserHandler implements PreHandler, PostHandler{

    @Override
    public void preHandle(AclContext context) {
        AuthUser<String> authUser = AuthManager.getAuthUser(context.getRequestToken());
        if(authUser != null){
            SecurityContexts.setAuthUser(authUser);
        }
    }

    @Override
    public void postHandle(AclContext context) {
        SecurityContexts.clearAuthUser();
    }

}